<?php
    $helper = Mage::helper('cms');
    $processor = $helper->getBlockTemplateProcessor();
    $id = "emtabs_".md5(uniqid(rand()));
    if ($this->getData('tabs_unique_id'))
        $id = $this->getData('tabs_unique_id');
?>
<div class="em-tabs-widget tabs-widget <?php echo $this->getCustomClass() ?>">
    <?php if($this->getTitle()): ?>
        <div class="widget-title em-widget-title">
    		<h3><span><?php echo $this->getTitle()?></span></h3>
    	</div>
    <?php endif;?>
    <?php if($processor->filter($this->getShortDescription())):?><div class="block-description"><?php echo $processor->filter($this->getShortDescription())?></div><?php endif;?>
    <div class="em-tabs emtabs" id="<?php echo $id ?>">
        <ul class="em-tabs-control tabs-control">
            <?php for($i = 1;$i <= 10;$i++):?>
                <?php if($this->getTitleTab($i)):?>
                    <li>
                        <a href="#tab_<?php echo $id ?>_<?php echo $i;?>" data-hover="<?php echo $this->getTitleTab($i)?>"> <span class="icon tab_<?php echo $id ?>_<?php echo $i;?>"></span><?php echo $this->getTitleTab($i)?></a>
                    </li>
                <?php endif;?>
            <?php endfor;?>
        </ul>
        <div class="em-tabs-content tab-content-default">
            <?php for($i = 1;$i <= 10;$i++):?>
                <?php if($this->getTitleTab($i)):?>
                    <div id="tab_<?php echo $id ?>_<?php echo $i;?>" class="tab-pane tab-item content_tab_<?php echo $id ?>_<?php echo $i;?>">
                        <?php
                        //Show Static Block
                        echo $processor->filter($this->getStaticBlock($i));
                        //Show Widget Instance
                        //echo $processor->filter($this->getWidgetInstance($i));
                        ?>
                    </div>
                <?php endif;?>
            <?php endfor;?>
        </div>
    </div>
</div>
<script type="text/javascript">            
    jQuery('#<?php echo $id ?>').responsiveTabs({                                    
        animation:'fade',
        startCollapsed:'accordion',
        active: 0, 
		activateState: function(e,state){
			if(state.newState == 'accordion'){   	
				var ulTab = jQuery(this).find("ul.r-tabs-nav");
				var activeTab = jQuery(this).find("div.r-tabs-state-active");
				if(activeTab.length==0){
					jQuery(ulTab).find("li:first-child a").click();
				}
			}
		}, 
        activate: function(event,tab){
            var id = tab.id + 1;            
            var $_eheight = jQuery('#tab_<?php echo $id ?>_'+id).find('.em-filterproducts-grid');
			setTimeout(function(){
                setEqualElement($_eheight,'.product-name');
            },400);
        },  
    });
</script>